#!/bin/sh
# postinst script for fossology-web
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    configure)
    # link the apache config for fossology
    if [ -f "/etc/apache2/sites-enabled/fossology.conf" ]; then
    rm -rf  /etc/apache2/sites-enabled/fossology.conf
    fi
    sed -r -i.bak 's/;? ?upload_max_filesize ?= ?[0-9]+[kmgKMG]*/upload_max_filesize = 750M/' /etc/php*/apache2/php.ini
    ln -s /etc/fossology/conf/fo-apache.conf /etc/apache2/sites-enabled/fossology.conf
    # need to run fo-postinstall web and agent stuff
    /usr/lib/fossology/fo-postinstall --web-only
    invoke-rc.d apache2 restart
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


